<?php defined('SYSPATH') or die('No direct script access.');
/**
 * controller class for automatic templating.
 *
 */
class Controller_Template extends Kohana_Controller_Template {

	/**
	 * Loads the UserInfo.
	 */
	public function before()
	{
		parent::before();
        $this->set_no_cache();

        $request = Request::initial();
        $reqinfo = array(
            'directory'  => $request->directory(),
            'controller' => $request->controller(),
            'action'     => $request->action(),
        );

        $this->template->set('request', $reqinfo);
		return TRUE;
	}
	
	protected function pagination ($count, $limit = 10, $page_type = 'route', $page_key = 'param1', $views = 'pagination/floating')
    {
        $page_config = array(
            'current_page'      => array('source' => $page_type, 'key' => $page_key),
            'total_items'       => (int) $count,
            'items_per_page'    => (int) $limit,
            'view'              => $views,
        );

		return Pagination::factory($page_config)->render();
    }
    
    private function set_no_cache ()
    {
        header("Expires: Mon, 26 Jul 1970 05:00:00 GMT");
        header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
        header("Cache-Control: no-cache, must-revalidate");
        header("Pragma: no-cache");
    }
} // End Controller_Template
